﻿using System;
using DMS.Business.Utility;

namespace DMS.Business.Modules.Organization
{
    /// <summary>
    /// 内部用户
    /// </summary>
    public class ExtendUser
    {
        #region 数据成员/内部成员

        protected string _ID;
        protected string _UserName;
        protected SexTypes _Sex = SexTypes.Unknow;
        protected string _Mobile;
        private string _UserType = "3";

        public string UserType
        {
            get { return _UserType; }
        }
        protected string _PositionName;
        private ActorStatus _Status = ActorStatus.Actived;
        protected bool _IsTemporary = false;
        private string _Email;
        
        protected Department _Dept = null;
        private string _DeptID = "";

        public string DeptID
        {
            get { return _DeptID; }
        }
        private string _DeptIDPath;

        public string DeptIDPath
        {
            get { return _DeptIDPath; }
        }
        //protected string _DeptCode;
        //protected string _DeptCodePath;
        
        #endregion

        #region 成员属性

        public string ID
        {
            get { return _ID; }
        }

        public string UserName
        {
            get { return _UserName; }
            set { _UserName = value; }
        }

        public string Mobile
        {
            get { return _Mobile; }
            set { _Mobile = value; }
        }

        public string Email
        {
            get { return _Email; }
            set { _Email = value; }
        }

        public ActorTypes ActorType
        {
            get
            {
                return ActorTypes.User;
            }
        }

        public ActorStatus Status
        {
            get { return _Status; }
            set { _Status = value; }
        }
        /// <summary>
        /// Sex
        /// </summary>
        public SexTypes Sex
        {
            get
            {
                return this._Sex;
            }
            set
            {
                this._Sex = value;
            }
        }
        /// <summary>
        /// 岗位名称
        /// </summary>
        public string PositionName
        {
            get
            {
                return this._PositionName;
            }
            set
            {
                this._PositionName = value;
            }
        }

        /// <summary>
        /// 用户所在部门
        /// </summary>
        public Department Dept
        {
            get
            {
                if (this._DeptID != "" && this._Dept == null)
                {
                    this._Dept = UserHelper.GetDepartmentByID(this._DeptID);
                }
                return this._Dept;
            }
            set
            {
                if (value != null)
                {
                    this._DeptID = value.ID;
                    this._DeptIDPath = value.IDPath;
                    this._Dept = value;
                }
                else
                {
                    this._DeptID = "";
                    this._DeptIDPath = string.Empty;
                    this._Dept = null;
                }
            }
        }   

        #endregion

        #region 构造函数
        public ExtendUser(string id)
        {
            this._ID = id;
        }
        #endregion

        //#region 成员方法
        //public override void Save()
        //{
        //    throw new InvalidOperationException("内部用户信息不能通过本方法更新");
        //}
        //#endregion

    }
}
